package com.example.yls.demoa;

import android.content.Intent;
import android.net.Uri;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;


public class MainActivity extends AppCompatActivity {

    private Button btnFirst;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        btnFirst=findViewById(R.id.btn_first);

        btnFirst.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                /* 显式调用
                Intent intent=new Intent(MainActivity.this,
                        SecondActivity.class);*/

              /*  隐式调用
                Intent intent = new Intent("com.example.administrator." +
                        "activitytest.ACTION_START");*/

                //跨应用显式隐式调用
                // create Intent object (param1: start what action)，ACTION_VIEW is system action
                Intent intent = new Intent(Intent.ACTION_VIEW);
                //给Intent设置数据，将网址通过parse解析然后来设置网址
                //set Intent  data ,put website parsed Uri object
                intent.setData(Uri.parse("http://www.baidu.com"));
                startActivity(intent);
            }
        });
    }
}
